function searchField() {
	var text = $('#search').val().toLowerCase();
	
		$('.listRow').each(function(){
			//determine where the text is in the list
			var beerName = $(this).find('.beerName').html().toLowerCase();;
			if(beerName.indexOf(text) == -1){
				$(this).css('display', 'none');
			}else{
				$(this).css('display', 'block');	
			}
			
		});	
}
	

function getStars(user_rating){
		
	var starTotal = 5;
	var rating = user_rating; 
	
	var list = '<ul class="starWrapper">';
	var half = rating-Math.floor(rating);
	var yellow = rating-half;
	var totalMinusRating = starTotal - Math.round(rating);
	
	for (var i = 0; i < yellow; i++){
		list += "<li class='yellowStar'>";
		list += "</li>";
	}
	
	for(var i = 0; i< Math.round(half); i++){
		list += "<li class='halfStar'>";
		list += "</li>";
	}
	
	for (var i = 0; i < totalMinusRating; i++){
		list += "<li class='greyStar'>";
		list += "</li>";
	}

	list += "</ul>";
	
	return list;
	//$('.listPageRatingWrapper').html(list);
	//$('.listRatingNumbers').html('<p>' + rating + '</p>');

}




$(function(){

		$('.listContainer').show();

	var windowWidth = $(window).width();
 	
 	if (windowWidth>= 500){
 		fontResizeLarge();
 	} else{
 		fontResizeSmall();
 	}

	
	
	function fontResizeLarge(){
		$('.beerName').each(function(){
			var beerName = $(this).text();
			var length = beerName.length;

			if((length >= 1) && (length <= 10)){
				$(this).css("font-size", "30px");
			} else if((length >= 10) && (length <= 20)){
				$(this).css('font-size', '26px');
			} else if ((length >= 20) && (length <= 30)){
				$(this).css('font-size', '22px');
			} else if ((length >= 30) && (length <= 40)) {
				$(this).css('font-size', '18px');
			} else if ((length >= 40) && (length <= 50)) {
				$(this).css('font-size', '16px');
			} else if ((length >= 50) && (length <= 60)) {
				$(this).css('font-size', '14px');
			}
		})

		$('#beerHeader h2').each(function(){
			var beerHeader = $(this).text();
			var length = beerHeader.length;

			if((length >= 1) && (length <= 10)){
				$(this).css("font-size", "32px");
			} else if((length >= 10) && (length <= 20)){
				$(this).css('font-size', '28px');
			} else if ((length >= 20) && (length <= 30)){
				$(this).css('font-size', '26px');
			} else if ((length >= 30) && (length <= 40)) {
				$(this).css('font-size', '24px');
			} else if ((length >= 40) && (length <= 50)) {
				$(this).css('font-size', '22px');
			} else if ((length >= 50) && (length <= 60)) {
				$(this).css('font-size', '20px');
			}
		})

	};	

	/*function fontResizeSmall(){
		$('.beerName').each(function(){
			var beerName = $(this).text();
			var length = beerName.length;

			if((length >= 1) && (length <= 10)){
				$(this).css("font-size", "18px");
			} else if((length >= 10) && (length <= 20)){
				$(this).css('font-size', '16px');
			} else if ((length >= 20) && (length <= 30)){
				$(this).css('font-size', '14px');
			} else if ((length >= 30) && (length <= 40)) {
				$(this).css('font-size', '12px');
			} else if ((length >= 40) && (length <= 50)) {
				$(this).css('font-size', '10px');
			} else if ((length >= 50) && (length <= 60)) {
				$(this).css('font-size', '8px');
			}
		})

		$('#beerHeader h2').each(function(){
			var beerHeader = $(this).text();
			var length = beerHeader.length;

			if((length >= 1) && (length <= 10)){
				$(this).css("font-size", "20px");
			} else if((length >= 10) && (length <= 20)){
				$(this).css('font-size', '18px');
			} else if ((length >= 20) && (length <= 30)){
				$(this).css('font-size', '16px');
			} else if ((length >= 30) && (length <= 40)) {
				$(this).css('font-size', '14px');
			} else if ((length >= 40) && (length <= 50)) {
				$(this).css('font-size', '12px');
			} else if ((length >= 50) && (length <= 60)) {
				$(this).css('font-size', '10px');
			}
		})	


	};*/

	/*private int getScale(){
	    Display display = ((WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); 
	    int width = display.getWidth(); 
	    Double val = new Double(width)/new Double(PIC_WIDTH);
	    val = val * 100d;
	    return val.intValue();
	}

	WebView web = new WebView(this);
	web.setPadding(0, 0, 0, 0);
	web.setInitialScale(getScale());*/
	


	 /*** LIMIT AMOUNT OF TXT SHOWN ***/

	/*$('#beerCopy p').each(function(){
		var limit = 300;
        var chars = $("#beerCopy p").text(); 
        if (chars.length > limit) {
            var visiblePart = $("<span> "+ chars.substr(0, limit) +"</span>");
            var dots = $("<span class='dots'>... </span>");
            var hiddenPart = $("<span class='more'>"+ chars.substr(limit) +"</span>");
            var readMore = $("<span class='read-more'>Read More</span>");
            readMore.click(function() {
                $(this).prev().remove(); // remove dots
                $(this).next().show('slow');
                $(this).remove(); // remove 'read more'

            	
            });

           

            $("#beerCopy p").empty()
                .append(visiblePart)
                .append(dots)
                .append(readMore)
                .append(hiddenPart);
        }
    })*/     

})


	
